package com.example.rxjavamodule.login.core;

import com.example.rxjavamodule.login.Bean.ResponseResult;
import com.example.rxjavamodule.login.Bean.SuccessData;

import io.reactivex.Observable;

public class LoginEngine {

    // 起点
    public static Observable<ResponseResult> login(String name, String pwd){
        ResponseResult responseResult  = new ResponseResult();

        if("Derry".equals(name) && "123456".equals(pwd)){ // 登录成功
            SuccessData data = new SuccessData();
            data.setId(45674565);
            data.setName("Derry登录成功");

            responseResult.setData(data);
            responseResult.setCode(200);
            responseResult.setMessage("登录成功");
        } else {  // 登录失败
            responseResult.setData(null);
            responseResult.setCode(404);
            responseResult.setMessage("登陆失败");
        }

        return Observable.just(responseResult);
    }
}
